/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jFLogradouros.java
 *
 * Created on 28/05/2012, 12:50:04
 */

package ecommercial;

import ecommercial.Classes.Bairros;
import ecommercial.Classes.ClassConecta;
import ecommercial.Classes.ComboItem;
import ecommercial.Classes.Funcoes;
import ecommercial.Classes.Logradouros;
import ecommercial.Classes.TiposLogradouros;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author vitiazze
 */
public class jFLogradouros extends javax.swing.JDialog {

    /** Creates new form jFLogradouros */
    public jFLogradouros() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        buscarjButton = new javax.swing.JButton();
        novojButton = new javax.swing.JButton();
        editarjButton = new javax.swing.JButton();
        salvarjButton = new javax.swing.JButton();
        salvarMaisjButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        alterarjButton = new javax.swing.JButton();
        excluirjButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        sairjButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cepjFormattedTextField = new javax.swing.JFormattedTextField();
        tipoLogradourojComboBox = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        tipoLogradourojButton = new javax.swing.JButton();
        atualizaTipoLogradourojButton = new javax.swing.JButton();
        logradourojTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        bairrosjComboBox = new javax.swing.JComboBox();
        linkMapajTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        atualizaBairrojButton = new javax.swing.JButton();
        cidadejTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        estadojTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        paisjTextField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        gradeLogradourosjTable = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ecommercial.EcommercialApp.class).getContext().getResourceMap(jFLogradouros.class);
        jToolBar1.setBackground(resourceMap.getColor("jToolBar1.background")); // NOI18N
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        buscarjButton.setBackground(resourceMap.getColor("buscarjButton.background")); // NOI18N
        buscarjButton.setIcon(resourceMap.getIcon("buscarjButton.icon")); // NOI18N
        buscarjButton.setText(resourceMap.getString("buscarjButton.text")); // NOI18N
        buscarjButton.setFocusable(false);
        buscarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buscarjButton.setName("buscarjButton"); // NOI18N
        buscarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buscarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(buscarjButton);

        novojButton.setBackground(resourceMap.getColor("novojButton.background")); // NOI18N
        novojButton.setIcon(resourceMap.getIcon("novojButton.icon")); // NOI18N
        novojButton.setText(resourceMap.getString("novojButton.text")); // NOI18N
        novojButton.setFocusable(false);
        novojButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        novojButton.setName("novojButton"); // NOI18N
        novojButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        novojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novojButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(novojButton);

        editarjButton.setBackground(resourceMap.getColor("editarjButton.background")); // NOI18N
        editarjButton.setIcon(resourceMap.getIcon("editarjButton.icon")); // NOI18N
        editarjButton.setText(resourceMap.getString("editarjButton.text")); // NOI18N
        editarjButton.setFocusable(false);
        editarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarjButton.setName("editarjButton"); // NOI18N
        editarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(editarjButton);

        salvarjButton.setBackground(resourceMap.getColor("salvarjButton.background")); // NOI18N
        salvarjButton.setIcon(resourceMap.getIcon("salvarjButton.icon")); // NOI18N
        salvarjButton.setText(resourceMap.getString("salvarjButton.text")); // NOI18N
        salvarjButton.setFocusable(false);
        salvarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarjButton.setName("salvarjButton"); // NOI18N
        salvarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarjButton);

        salvarMaisjButton.setBackground(resourceMap.getColor("salvarMaisjButton.background")); // NOI18N
        salvarMaisjButton.setIcon(resourceMap.getIcon("salvarMaisjButton.icon")); // NOI18N
        salvarMaisjButton.setText(resourceMap.getString("salvarMaisjButton.text")); // NOI18N
        salvarMaisjButton.setFocusable(false);
        salvarMaisjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarMaisjButton.setName("salvarMaisjButton"); // NOI18N
        salvarMaisjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarMaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarMaisjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarMaisjButton);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        alterarjButton.setBackground(resourceMap.getColor("alterarjButton.background")); // NOI18N
        alterarjButton.setIcon(resourceMap.getIcon("alterarjButton.icon")); // NOI18N
        alterarjButton.setText(resourceMap.getString("alterarjButton.text")); // NOI18N
        alterarjButton.setFocusable(false);
        alterarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        alterarjButton.setName("alterarjButton"); // NOI18N
        alterarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        alterarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(alterarjButton);

        excluirjButton.setBackground(resourceMap.getColor("excluirjButton.background")); // NOI18N
        excluirjButton.setIcon(resourceMap.getIcon("excluirjButton.icon")); // NOI18N
        excluirjButton.setText(resourceMap.getString("excluirjButton.text")); // NOI18N
        excluirjButton.setFocusable(false);
        excluirjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        excluirjButton.setName("excluirjButton"); // NOI18N
        excluirjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        excluirjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(excluirjButton);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        sairjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        sairjButton.setIcon(resourceMap.getIcon("sairjButton.icon")); // NOI18N
        sairjButton.setText(resourceMap.getString("sairjButton.text")); // NOI18N
        sairjButton.setFocusable(false);
        sairjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        sairjButton.setName("sairjButton"); // NOI18N
        sairjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        sairjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(sairjButton);

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        try {
            cepjFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cepjFormattedTextField.setName("cepjFormattedTextField"); // NOI18N

        tipoLogradourojComboBox.setName("tipoLogradourojComboBox"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        tipoLogradourojButton.setIcon(resourceMap.getIcon("tipoLogradourojButton.icon")); // NOI18N
        tipoLogradourojButton.setText(resourceMap.getString("tipoLogradourojButton.text")); // NOI18N
        tipoLogradourojButton.setContentAreaFilled(false);
        tipoLogradourojButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        tipoLogradourojButton.setName("tipoLogradourojButton"); // NOI18N
        tipoLogradourojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tipoLogradourojButtonActionPerformed(evt);
            }
        });

        atualizaTipoLogradourojButton.setIcon(resourceMap.getIcon("atualizaTipoLogradourojButton.icon")); // NOI18N
        atualizaTipoLogradourojButton.setText(resourceMap.getString("atualizaTipoLogradourojButton.text")); // NOI18N
        atualizaTipoLogradourojButton.setContentAreaFilled(false);
        atualizaTipoLogradourojButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        atualizaTipoLogradourojButton.setName("atualizaTipoLogradourojButton"); // NOI18N
        atualizaTipoLogradourojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaTipoLogradourojButtonActionPerformed(evt);
            }
        });

        logradourojTextField.setText(resourceMap.getString("logradourojTextField.text")); // NOI18N
        logradourojTextField.setName("logradourojTextField"); // NOI18N
        logradourojTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                logradourojTextFieldKeyReleased(evt);
            }
        });

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        bairrosjComboBox.setName("bairrosjComboBox"); // NOI18N
        bairrosjComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bairrosjComboBoxActionPerformed(evt);
            }
        });

        linkMapajTextField.setText(resourceMap.getString("linkMapajTextField.text")); // NOI18N
        linkMapajTextField.setName("linkMapajTextField"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setContentAreaFilled(false);
        jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        atualizaBairrojButton.setIcon(resourceMap.getIcon("atualizaBairrojButton.icon")); // NOI18N
        atualizaBairrojButton.setText(resourceMap.getString("atualizaBairrojButton.text")); // NOI18N
        atualizaBairrojButton.setContentAreaFilled(false);
        atualizaBairrojButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        atualizaBairrojButton.setName("atualizaBairrojButton"); // NOI18N
        atualizaBairrojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaBairrojButtonActionPerformed(evt);
            }
        });

        cidadejTextField.setEditable(false);
        cidadejTextField.setText(resourceMap.getString("cidadejTextField.text")); // NOI18N
        cidadejTextField.setName("cidadejTextField"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        estadojTextField.setEditable(false);
        estadojTextField.setText(resourceMap.getString("estadojTextField.text")); // NOI18N
        estadojTextField.setName("estadojTextField"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        paisjTextField.setEditable(false);
        paisjTextField.setText(resourceMap.getString("paisjTextField.text")); // NOI18N
        paisjTextField.setName("paisjTextField"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(98, 98, 98))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(cepjFormattedTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
                                    .addComponent(tipoLogradourojComboBox, 0, 134, Short.MAX_VALUE)
                                    .addComponent(bairrosjComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 134, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jButton1, 0, 0, Short.MAX_VALUE)
                                    .addComponent(tipoLogradourojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 13, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(atualizaTipoLogradourojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(atualizaBairrojButton, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(157, 157, 157)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(154, 154, 154)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel3)
                    .addComponent(logradourojTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                    .addComponent(linkMapajTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                    .addComponent(jLabel5)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cidadejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(estadojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(paisjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(155, 155, 155))
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cidadejTextField, estadojTextField});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(linkMapajTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(logradourojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cepjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tipoLogradourojButton)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(tipoLogradourojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(5, 5, 5))))
                    .addComponent(atualizaTipoLogradourojButton))
                .addGap(6, 6, 6)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(atualizaBairrojButton)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bairrosjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cidadejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(estadojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(paisjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 732, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        gradeLogradourosjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "#Id", "Tipo", "Logradouro", "Bairro", "Cidade", "Estado", "País"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradeLogradourosjTable.setName("gradeLogradourosjTable"); // NOI18N
        gradeLogradourosjTable.getTableHeader().setReorderingAllowed(false);
        gradeLogradourosjTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gradeLogradourosjTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(gradeLogradourosjTable);
        gradeLogradourosjTable.getColumnModel().getColumn(0).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(0).setPreferredWidth(20);
        gradeLogradourosjTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title0")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(1).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(1).setPreferredWidth(50);
        gradeLogradourosjTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title1")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(2).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(2).setPreferredWidth(100);
        gradeLogradourosjTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title2")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(3).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(3).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title3")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(4).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(4).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title4")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(5).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(5).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title5")); // NOI18N
        gradeLogradourosjTable.getColumnModel().getColumn(6).setResizable(false);
        gradeLogradourosjTable.getColumnModel().getColumn(6).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("gradeLogradourosjTable.columnModel.title6")); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 752, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    ClassConecta conexao = new ClassConecta();

    ComboItem comboBairro;

    ComboItem comboTipoLogradouro;

    public Integer codLogradouro;


//******************************************************************************************************
    public void getGradeLogradouros() throws ParseException{
       //Consultar Logradouros
        Logradouros oLogradouro = new Logradouros();


        if ( logradourojTextField.getText().length() > 0 ){
            oLogradouro.setLogradouro(logradourojTextField.getText()+"%");
        }

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"#Id", "Tipo", "Logradouro", "Bairro", "Cidade", "Estado", "País"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradeLogradourosjTable.setModel(modeloTabela);
        gradeLogradourosjTable.getColumnModel().getColumn(0).setPreferredWidth(25);
        gradeLogradourosjTable.getColumnModel().getColumn(1).setPreferredWidth(30);
        gradeLogradourosjTable.getColumnModel().getColumn(2).setPreferredWidth(120);
        gradeLogradourosjTable.getColumnModel().getColumn(3).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(4).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(5).setPreferredWidth(80);
        gradeLogradourosjTable.getColumnModel().getColumn(6).setPreferredWidth(80);



try {


            resultSet = oLogradouro.getConsultar();

            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                modeloTabela.addRow(new String[]{
                    Funcoes.getCodigoFormat(resultSet.getInt("COD_LOGRADOURO")),
                    resultSet.getString("TIPO"),
                    resultSet.getString("LOGRADOURO") ,
                    resultSet.getString("BAIRRO"),
                    resultSet.getString("CIDADE"),
                    resultSet.getString("ESTADO"),
                    resultSet.getString("PAIS"),
                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }

           }

    public void getFieldLogradouro(int codLogradouro) throws ParseException{

        Logradouros oLogradouro = new Logradouros();
        ResultSet rs = null;
        oLogradouro.setCod_logradouro(codLogradouro);

        try {
            rs = oLogradouro.getConsultar();
            rs.next();

            ComboItem oItem = new ComboItem(rs.getInt("COD_BAIRRO"), rs.getString("BAIRRO"));
            ComboItem oItem2 = new ComboItem(rs.getInt("COD_TIPO_LOGRADOURO"), rs.getString("TIPO"));

            //Pegar campos
            cepjFormattedTextField.setText(rs.getString("CEP"));
            bairrosjComboBox.setSelectedItem(oItem);
            tipoLogradourojComboBox.setSelectedItem(oItem2);
            logradourojTextField.setText(rs.getString("LOGRADOURO"));
            linkMapajTextField.setText(rs.getString("LINK_MAPA"));

        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void sairjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairjButtonActionPerformed
        // TODO add your handling code here:
        if (!novojButton.isEnabled()){
                Object[] options = {"Sim", "Não"};
                int sd = JOptionPane.showOptionDialog(null, "Deseja realmente SAIR?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                if (sd != 0) {
                    return;
                }

                this.dispose();

            }else{

                this.dispose();

            }

    }//GEN-LAST:event_sairjButtonActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:

        salvarjButton.setEnabled(false);
        salvarMaisjButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        novojButton.setEnabled(true);
        cepjFormattedTextField.grabFocus();

        ClassConecta.conecta();

        atualizaTipoLogradourojButtonActionPerformed(null);
        atualizaBairrojButtonActionPerformed(null);
        buscarjButtonActionPerformed(null);

    }//GEN-LAST:event_formWindowOpened

    private void novojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novojButtonActionPerformed
        // TODO add your handling code here:
        novojButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        buscarjButton.setEnabled(true);
        salvarjButton.setEnabled(true);
        salvarMaisjButton.setEnabled(true);
        cepjFormattedTextField.grabFocus();
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFBairros.class.getName()).log(Level.SEVERE, null, ex);
        }
        cepjFormattedTextField.setText("");
        linkMapajTextField.setText("");
        logradourojTextField.setText("");
        
    }//GEN-LAST:event_novojButtonActionPerformed

    private void salvarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarjButtonActionPerformed
        // TODO add your handling code here:
            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            alterarjButton.setEnabled(false);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);
            editarjButton.setEnabled(true);
            
            Logradouros oLogradouro = new Logradouros();

            comboBairro = (ComboItem) bairrosjComboBox.getSelectedItem();
            comboTipoLogradouro = (ComboItem) tipoLogradourojComboBox.getSelectedItem();

            if(logradourojTextField.getText().equals("")){

                JOptionPane.showMessageDialog(null, "O campo LOGRADOURO é obrigatório", "ATENÇÃO Mensagem do Sistema", JOptionPane.INFORMATION_MESSAGE);
                novojButtonActionPerformed(null);
            }else{

                oLogradouro.setCep(cepjFormattedTextField.getText());
                oLogradouro.setLink_mapa(linkMapajTextField.getText());
                oLogradouro.setLogradouro(logradourojTextField.getText().trim().toUpperCase());
                oLogradouro.setCod_bairro(comboBairro.getId());
                oLogradouro.setCod_tipo_logradouro(comboTipoLogradouro.getId());

                oLogradouro.setCadastrar();
            try {
                ClassConecta.con.commit();
                ClassConecta.con.setAutoCommit(true);
            } catch (SQLException ex) {
                Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                getGradeLogradouros();
            } catch (ParseException ex) {
                Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
            }

            }
    }//GEN-LAST:event_salvarjButtonActionPerformed

    private void atualizaBairrojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaBairrojButtonActionPerformed
        // TODO add your handling code here:
        try {
            Bairros oBairro = new Bairros();
            ResultSet rs = null;

            rs = oBairro.getConsultar();
            bairrosjComboBox.removeAllItems();
            while (rs.next()) {
                bairrosjComboBox.addItem(new ComboItem(rs.getInt("COD_BAIRRO"), rs.getString("BAIRRO")));
            }
            bairrosjComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizaBairrojButtonActionPerformed

    private void atualizaTipoLogradourojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaTipoLogradourojButtonActionPerformed
        // TODO add your handling code here:
        try {
            TiposLogradouros oTipoLogradouro = new TiposLogradouros();
            ResultSet rs = null;

            rs = oTipoLogradouro.getConsultar();
            tipoLogradourojComboBox.removeAllItems();
            while (rs.next()) {
                tipoLogradourojComboBox.addItem(new ComboItem(rs.getInt("COD_TIPO_LOGRADOURO"), rs.getString("TIPO")));
            }
            bairrosjComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizaTipoLogradourojButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        jFBairros oFormBairro = new jFBairros();

        oFormBairro.setTitle("Cadastro de bairros");
        oFormBairro.pack();
        oFormBairro.setLocationRelativeTo(null);
        oFormBairro.setModal(true);
        oFormBairro.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tipoLogradourojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tipoLogradourojButtonActionPerformed
        // TODO add your handling code here:
        jFTiposLogradouros oFormTipoLogradouro = new jFTiposLogradouros();

        oFormTipoLogradouro.pack();
        oFormTipoLogradouro.setLocationRelativeTo(null);
        oFormTipoLogradouro.setModal(true);
        oFormTipoLogradouro.setVisible(true);
    }//GEN-LAST:event_tipoLogradourojButtonActionPerformed

    private void buscarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarjButtonActionPerformed
        try {
            // TODO add your handling code here:
            getGradeLogradouros();
        } catch (ParseException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buscarjButtonActionPerformed

    private void salvarMaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarMaisjButtonActionPerformed
        // TODO add your handling code here:
        salvarjButtonActionPerformed(null);
        novojButtonActionPerformed(null);
    }//GEN-LAST:event_salvarMaisjButtonActionPerformed

    private void gradeLogradourosjTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gradeLogradourosjTableMouseClicked
        // TODO add your handling code here:
        editarjButton.setEnabled(true);
            codLogradouro = Integer.parseInt(gradeLogradourosjTable.getValueAt(gradeLogradourosjTable.getSelectedRow(), 0).toString());
            if (codLogradouro == 0) {
                return;
            }
        try {
            getFieldLogradouro(codLogradouro);
        } catch (ParseException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_gradeLogradourosjTableMouseClicked

    private void bairrosjComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bairrosjComboBoxActionPerformed
        // TODO add your handling code here:
        try {
            Bairros oBairro = new Bairros();
            ResultSet rs = null;

            comboBairro = (ComboItem) bairrosjComboBox.getSelectedItem();
            oBairro.setCod_Bairro(comboBairro.getId());
            rs = oBairro.getConsultar();

            while (rs.next()){
                cidadejTextField.setText(rs.getString("CIDADE"));
                estadojTextField.setText(rs.getString("ESTADO"));
                paisjTextField.setText(rs.getString("PAIS"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(jFCidades.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_bairrosjComboBoxActionPerformed

    private void editarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarjButtonActionPerformed
        // TODO add your handling code here:
            novojButton.setEnabled(false);
            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            editarjButton.setEnabled(false);
            alterarjButton.setEnabled(true);
            excluirjButton.setEnabled(true);
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_editarjButtonActionPerformed

    private void alterarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alterarjButtonActionPerformed
        // TODO add your handling code here:
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        comboBairro = (ComboItem) bairrosjComboBox.getSelectedItem();
        comboTipoLogradouro = (ComboItem) tipoLogradourojComboBox.getSelectedItem();
        @SuppressWarnings("LocalVariableHidesMemberVariable")

        Logradouros oLogradouro = new Logradouros();
        oLogradouro.setCod_logradouro(codLogradouro);

        oLogradouro.setCep(cepjFormattedTextField.getText());
        oLogradouro.setLink_mapa(linkMapajTextField.getText());
        oLogradouro.setCod_tipo_logradouro(comboTipoLogradouro.getId());
        oLogradouro.setCod_bairro(comboBairro.getId());
        oLogradouro.setLogradouro(logradourojTextField.getText().trim().toUpperCase());

        oLogradouro.setAlterar(conexao);
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            getGradeLogradouros();
        } catch (ParseException ex) {
            Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_alterarjButtonActionPerformed

    private void excluirjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirjButtonActionPerformed
        // TODO add your handling code here:
        Object[] options = {"Sim", "Não"};
        int sd =
                JOptionPane.showOptionDialog(null, "Deseja realmente EXCLUIR esse registro?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[0]);

        if (sd != 0) {
            return;
        }
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        Logradouros oLogradouro = new Logradouros();
        oLogradouro.setCod_logradouro(codLogradouro);

        oLogradouro.setExcluir();
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPaises.class.getName()).log(Level.SEVERE, null, ex);
        }

            cepjFormattedTextField.setText("");
            linkMapajTextField.setText("");
            logradourojTextField.setText("");
        try {
            getGradeLogradouros();
        } catch (ParseException ex) {
            Logger.getLogger(jFPaises.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_excluirjButtonActionPerformed

    private void logradourojTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_logradourojTextFieldKeyReleased
        // TODO add your handling code here:
        if (!alterarjButton.isEnabled()){
            try {
                Logradouros oLogradouro = new Logradouros();
                oLogradouro.setLogradouro(logradourojTextField.getText());
                ResultSet rs = null;
                rs = oLogradouro.getConsultar();
                getGradeLogradouros();
            } catch (ParseException ex) {
                Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(jFLogradouros.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (logradourojTextField.getText().equals("")){
            logradourojTextField.setText("");
            cepjFormattedTextField.setText("");
            linkMapajTextField.setText("");
            editarjButton.setEnabled(false);
        }
    }//GEN-LAST:event_logradourojTextFieldKeyReleased

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jFLogradouros().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton alterarjButton;
    private javax.swing.JButton atualizaBairrojButton;
    private javax.swing.JButton atualizaTipoLogradourojButton;
    private javax.swing.JComboBox bairrosjComboBox;
    private javax.swing.JButton buscarjButton;
    private javax.swing.JFormattedTextField cepjFormattedTextField;
    private javax.swing.JTextField cidadejTextField;
    private javax.swing.JButton editarjButton;
    private javax.swing.JTextField estadojTextField;
    private javax.swing.JButton excluirjButton;
    private javax.swing.JTable gradeLogradourosjTable;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTextField linkMapajTextField;
    private javax.swing.JTextField logradourojTextField;
    private javax.swing.JButton novojButton;
    private javax.swing.JTextField paisjTextField;
    private javax.swing.JButton sairjButton;
    private javax.swing.JButton salvarMaisjButton;
    private javax.swing.JButton salvarjButton;
    private javax.swing.JButton tipoLogradourojButton;
    private javax.swing.JComboBox tipoLogradourojComboBox;
    // End of variables declaration//GEN-END:variables

}
